import axios from 'axios';
import qs from 'query-string';

export interface MenuTreeData {
  menuId: number;
  menuName: string;
  icon: string;
  orderNum: string;
  perms: string;
  component: string;
  status: string;
  children: MenuTreeData[];
  isLeaf: boolean;
}

export interface MenuTreeParams {
  menuName: string;
  status: string;
}

export function getMenuTree(params: MenuTreeParams) {
  return axios.get<MenuTreeData>('/api/system/menu/tree', {
    params,
    paramsSerializer: (obj) => {
      return qs.stringify(obj);
    },
  });
}
